package com.example.util;


import com.example.api.MailManger;
import com.example.api.RedisApi;
import com.example.pojo.User;
import com.example.service.UserService;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import javax.annotation.Resource;

public class mailtest {
    @Resource
    public UserService userService;

    @Test
    public void  malltest(){

        ClassPathXmlApplicationContext ctx =new ClassPathXmlApplicationContext("springMail.xml");
       MailManger mailManger =(MailManger) ctx.getBean("mailManger");
//       接收到前端发送来的邮箱
        String qqCode="2766319102@qq.com";
        //随机生成验证码
        String active ="123456";

        mailManger.placeOrder(qqCode,active);

//   将随机生成的验证码存到 redis中(60s)
        //进行验证码的接收判断 返回true与false;
        ClassPathXmlApplicationContext atx=
                new ClassPathXmlApplicationContext("springConfig.xml");
        RedisApi redisApi =(RedisApi) atx.getBean("redisApi");
        //phonecode进行分类以便查询
        redisApi.set("emailCode:"+qqCode,60,String.valueOf(qqCode));
    }

//    @Test
//    public void Login(){
//        User u =new User();
//        u.setUserNickname("cwc");
//        u.setUserPassword("1314521yx");
//        if (userService.(u)!=0){
//            System.out.println("登录成功");
//        }else{
//            System.out.println("登录失败");
//        }
//    }
}
